<html>
<head><meta charset="utf-8"><title>Order dependence of `Task · t-compiler/wg-incr-comp · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/index.html">t-compiler/wg-incr-comp</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Order.20dependence.20of.20.60Task.html">Order dependence of `Task</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="241713678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Order%20dependence%20of%20%60Task/near/241713678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Order.20dependence.20of.20.60Task.html#241713678">(Jun 06 2021 at 22:22)</a>:</h4>
<p>I've been experimenting locally with removing <code>TaskDeps.reads</code>, and just using <code>TaskDeps.read_set</code>. However, it appears that something is relying on the insertion order being preserved. If I just rely on the iteration order of the <code>FxHashSet</code> (where we previously iterated over <code>TaskDeps.reads</code>, then two incremental tests fail. If I switch it to use <code>linked_hash_set::LinkedHashSet</code>, then the tests pass</p>



<a name="241713756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Order%20dependence%20of%20%60Task/near/241713756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Order.20dependence.20of.20.60Task.html#241713756">(Jun 06 2021 at 22:24)</a>:</h4>
<p>the insertion order is itself pretty arbitrary (whatever order the query access its dependencies in), so I think that the problem arises from the order <em>changing</em>.  The failing tests both fail to recover a <code>DefId</code>, which suggests that we're incorrectly marking a query as green (e.g. we are somehow  losing track of edges). However, I don't see anything in the code that relies on the order of edges being unchanged</p>



<a name="241725911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Order%20dependence%20of%20%60Task/near/241725911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Order.20dependence.20of.20.60Task.html#241725911">(Jun 07 2021 at 03:54)</a>:</h4>
<p>Never mind - nothing was getting marked green incorrectly. Since the edges were in a different order during loading, marking the node green tried to load a different query before the <code>tcx.hir()</code> dependency. When the edges are loaded in order, the 'parent' dependency (e.g. <code>hir().local_def_id_to_hir_id</code> will always be run first, which prevents this problem)</p>



<a name="241805135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Order%20dependence%20of%20%60Task/near/241805135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Order.20dependence.20of.20.60Task.html#241805135">(Jun 07 2021 at 16:42)</a>:</h4>
<p>Can you elaborate on your reasoning? I am not sure I follow.<br>
Neither <code>tcx.hir()</code> nor <code>tcx.hir().local_def_id_to_hir_id</code> are queries.</p>



<a name="241830980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Order%20dependence%20of%20%60Task/near/241830980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Order.20dependence.20of.20.60Task.html#241830980">(Jun 07 2021 at 19:51)</a>:</h4>
<p>I didn't look to closely into it - the failing query was <code>lookup_deprecation_entry</code></p>



<a name="241831215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Order%20dependence%20of%20%60Task/near/241831215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Order.20dependence.20of.20.60Task.html#241831215">(Jun 07 2021 at 19:53)</a>:</h4>
<p>I see - I forgot that <code>tcx.hir()</code> doesn't actually invoke any queries</p>



<a name="241831300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Order%20dependence%20of%20%60Task/near/241831300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Order.20dependence.20of.20.60Task.html#241831300">(Jun 07 2021 at 19:54)</a>:</h4>
<p>what I think happened was something like <code>let res = tcx.first_query(val); tcx.second_query(res)</code> inside of a query impl</p>



<a name="241831333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Order%20dependence%20of%20%60Task/near/241831333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Order.20dependence.20of.20.60Task.html#241831333">(Jun 07 2021 at 19:54)</a>:</h4>
<p>when we tried to mark the deps of that query as green, we started with <code>second_query</code></p>



<a name="241831450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Order%20dependence%20of%20%60Task/near/241831450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Order.20dependence.20of.20.60Task.html#241831450">(Jun 07 2021 at 19:55)</a>:</h4>
<p>normally, we would have started with <code>first_query</code>, which would have failed, so we would never get to <code>second_query</code></p>



<a name="241833990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Order%20dependence%20of%20%60Task/near/241833990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Order.20dependence.20of.20.60Task.html#241833990">(Jun 07 2021 at 20:13)</a>:</h4>
<p>This could probably be reproduced without any of the hash set changes by inserting <code>tasl+deps.reads.reverse()</code> in the proper place</p>



<a name="241942641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/241847-t-compiler/wg-incr-comp/topic/Order%20dependence%20of%20%60Task/near/241942641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/241847-t-compiler/wg-incr-comp/topic/Order.20dependence.20of.20.60Task.html#241942641">(Jun 08 2021 at 15:59)</a>:</h4>
<p>Preserving the order of dependencies is needed for correctness. A query provider is still just a regular procedure. I don't have time right now but I'll try to come up with a good example tomorrow.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>